package com.itbaizhan.controller;

import com.itbaizhan.pojo.User;
import com.itbaizhan.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author spf
 * @date 2024/2/25
 * @time 16:21
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService iUserService;

    @GetMapping("/findAll")
    public List<User> findAll(){
        return iUserService.findAll();
    }

    @GetMapping("/findById")
    public User findById(@RequestParam("id") Long id) throws InterruptedException {
        TimeUnit.SECONDS.sleep(3);
        return iUserService.findById(id);
    }

}
